from PyQt5 import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys
from zhihu import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
import hello_rc


class MyMainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        super(MyMainWindow, self).__init__(parent)
        self.setupUi(self)
        self.things()
        self.sex = '女'
        self.zh_comboBox = '点赞区'
        self.zh_time = '60'
        self.zh_url = ''
        self.zh_people = ''
        self.zh_text = ''
        self.checkBoxVal = False
        self.checkBoxVal2 = False

    # 定义事件合集
    def things(self):
         # 将鼠标移出的事件
        self.lineEdit.editingFinished.connect(self.lineEditFun)
        self.lineEdit_2.editingFinished.connect(self.lineEdit_2Fun)
        self.lineEdit_3.editingFinished.connect(self.lineEdit_3Fun)
        # self.radioButton_2.toggled.connect(self.radioButton_2Fun)
        self.radioButton_2.toggled.connect(
            lambda: self.radioFun(self.radioButton_2))
        self.radioButton.toggled.connect(
            lambda: self.radioFun(self.radioButton))
        self.checkBox.stateChanged.connect(self.checkBoxFuc)
        self.checkBox_2.stateChanged.connect(self.checkBox_2Fuc)
        self.comboBox.currentIndexChanged.connect(self.comboBoxFuc)
        # self.textEdit.clicked.connect(self.textEditFun)
        self.pushButton.clicked.connect(self.send)

    # 定义槽函数

    def lineEditFun(self):
        # 获取输入的url地址
        self.zh_url = self.lineEdit.text()
        print(self.zh_url)
        # 获取发送的时间频率

    def lineEdit_2Fun(self):
        self.zh_time = self.lineEdit_2.text()
        # 要将用户的输入转为数字
        print(self.zh_time)
        # 获取最多发送的人数

    def lineEdit_3Fun(self):
        self.zh_people = self.lineEdit_3.text()
        print(self.zh_people)
    # 设置单选按钮

    def radioFun(self, btn):
        # print(btn.text())
        if btn.text() == '女':
            if btn.isChecked() == True:
                print(btn.text()+'被选中了')
                self.sex = btn.text()
            # else:
            #     print('没有选中女')
        if btn.text() == '男':
            if btn.isChecked() == True:
                print(btn.text()+'被选中了')
                self.sex = btn.text()
            # else:
            #     print('没有选中男')

    def checkBoxFuc(self):
        if self.checkBox.isChecked() == True:
            self.checkBoxVal = True
            print('1被选中啦')
        else:
            self.checkBoxVal = False
            print('1取消了')

    def checkBox_2Fuc(self):
        if self.checkBox_2.isChecked() == True:
            self.checkBoxVal2 = True
            print('2被选中啦')
        else:
            self.checkBoxVal2 = False
            print('2取消了')

    def comboBoxFuc(self):
        print(self.comboBox.currentText())
        self.zh_comboBox = self.comboBox.currentText()
        # 当点击按钮时获取多行文本

    def textEditFun(self):
        print(self.textEdit.toPlainText())
        self.zh_text = self.textEdit.toPlainText()
    # 发送私信

    def send(self):
        self.textEditFun()
        if self.zh_url == '' or self.zh_time == '' or self.zh_people == '' or self.zh_text == '':
            print('请检查必填项目')
            self.msg()
        else:
            print('必备项已填写,开始发送数据')
    # 消息弹出框
    def msg(self):
        reply=QMessageBox.information(self,"hahah","啦啦啦啦",QMessageBox.Yes | QMessageBox.No ,QMessageBox.Yes )
        print(reply)
        if reply == 16384:
            print('用户选择ok')
        else:
            print('用户取消')


if __name__ == "__main__":
    app = QApplication(sys.argv)
    win = MyMainWindow()
    win.show()
    sys.exit(app.exec_())
